/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.sunspotworld;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.IntervalMarker;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.Layer;
import org.jfree.ui.RectangleAnchor;
import org.jfree.ui.RefineryUtilities;
import org.jfree.ui.TextAnchor;

public class SensoresExternos extends ApplicationFrame
{
  public SensoresExternos(String paramString)
  {
    super(paramString);
    JPanel localJPanel = createDemoPanel();
    localJPanel.setPreferredSize(new Dimension(500, 270));
    HidroponiaHost.reportes.jPanel4.add(localJPanel);
  }

  private static CategoryDataset createDataset()
  {
    String alto = "alto";
    String promedio = "promedio";
    String bajo = "bajo";
    String promedioE = "encendido";
    String promedioA = "apagado";
    String luzC = "Luz";
    String tempC = "Temp";
    String promedioEnc = "Promedio (hr.)";
    DefaultCategoryDataset localDefaultCategoryDataset = new DefaultCategoryDataset();
    localDefaultCategoryDataset.addValue(1.0D, alto, luzC);
    localDefaultCategoryDataset.addValue(4.0D, alto, tempC);
    localDefaultCategoryDataset.addValue(5.0D, promedio, luzC);
    localDefaultCategoryDataset.addValue(7.0D, promedio, tempC);
    localDefaultCategoryDataset.addValue(4.0D, bajo, luzC);
    localDefaultCategoryDataset.addValue(3.0D, bajo, tempC);
    localDefaultCategoryDataset.addValue(6.0D, promedioE, promedioEnc);
    localDefaultCategoryDataset.addValue(8.0D, promedioA, promedioEnc);
    return localDefaultCategoryDataset;
  }

  private static JFreeChart createChart(CategoryDataset paramCategoryDataset)
  {
    JFreeChart localJFreeChart = ChartFactory.createBarChart("Sensores Externos", "Reporte", "Valor", paramCategoryDataset, PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot localCategoryPlot = (CategoryPlot)localJFreeChart.getPlot();
    localCategoryPlot.setRangePannable(true);
    NumberAxis localNumberAxis = (NumberAxis)localCategoryPlot.getRangeAxis();
    localNumberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer localBarRenderer = (BarRenderer)localCategoryPlot.getRenderer();
    localBarRenderer.setDrawBarOutline(false);
    localBarRenderer.setItemMargin(0.1D);
    localBarRenderer.setBaseItemLabelGenerator(new LabelGenerator());
    localBarRenderer.setBaseItemLabelsVisible(true);
    ItemLabelPosition localItemLabelPosition1 = new ItemLabelPosition(ItemLabelAnchor.INSIDE12, TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, -1.570796326794897D);
    localBarRenderer.setBasePositiveItemLabelPosition(localItemLabelPosition1);
    ItemLabelPosition localItemLabelPosition2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, -1.570796326794897D);
    localBarRenderer.setPositiveItemLabelPositionFallback(localItemLabelPosition2);
    CategoryAxis localCategoryAxis = localCategoryPlot.getDomainAxis();
    localCategoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    return localJFreeChart;
  }

  public static JPanel createDemoPanel()
  {
    JFreeChart localJFreeChart = createChart(createDataset());
    ChartPanel localChartPanel = new ChartPanel(localJFreeChart);
    localChartPanel.setMouseWheelEnabled(true);
    return localChartPanel;
  }

  /*public static void main(String[] paramArrayOfString)
  {
    BarChartDemo7 localBarChartDemo7 = new BarChartDemo7("JFreeChart: BarChartDemo7.java");
    localBarChartDemo7.pack();
    RefineryUtilities.centerFrameOnScreen(localBarChartDemo7);
    localBarChartDemo7.setVisible(true);
  }*/

  static class LabelGenerator extends StandardCategoryItemLabelGenerator
  {
    public String generateLabel(CategoryDataset paramCategoryDataset, int paramInt1, int paramInt2)
    {
      return paramCategoryDataset.getRowKey(paramInt1).toString();
    }
  }
}